/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package SessionBeans.actions;

import SessionBeans.entites.FolderService;
import api.action.crates.Server.DeleteFolderCrate;
import api.exception.TCloudAplicationException;
import entities.AccountHeader;
import entities.Folder;
import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;

/**
 *
 * @author Tomas
 */
@Stateless
@LocalBean
public class DeleteFolderService implements InvokeActionInterface<DeleteFolderCrate> {
    @EJB
    private FolderService folderService;
    
    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
    @Override
    public void processAction(DeleteFolderCrate actionData, Long userId, AccountHeader accHeader) throws TCloudAplicationException {
        Folder findedFolder = Utils.findFolder(accHeader.getRootFolder(), actionData.getPath());
        if (findedFolder == null) {
            throw new TCloudAplicationException(103, actionData.getPath());
        }
        folderService.deleteFolder(userId, findedFolder);
        
    }
}
